package com.example.idachuappone.cook.action;

import java.util.Calendar;
import java.util.List;

import com.example.idachuappone.cook.entity.City;
import com.example.idachuappone.cook.entity.CookResult;
import com.example.idachuappone.cook.entity.Tags;
import com.example.idachuappone.utils.AppShareData;
import com.lidroid.xutils.bitmap.BitmapGlobalConfig.BitmapCacheManagementTask;

public class CookAction {
	public String getTimeDay(String date) {
		int day = Calendar.getInstance().get(BitmapCacheManagementTask.MESSAGE_CLEAR_MEMORY);
		int time = Integer.parseInt(date.substring(date.lastIndexOf("-") + 1));
		if (time == day) {
			return "\u4eca\u5929";
		}
		if (time == day + 1) {
			return "\u660e\u5929";
		}
		return time == day + 2 ? "\u540e\u5929" : "";
	}

	public int getBreedIndex(String breed, List<Tags> list) {
		for (int i = 0; i < list.size(); i++) {
			if (breed.equals(list.get(i).getName())) {
				return i;
			}
		}
		return 0;
	}

	public String getBreed(String breed, List<Tags> list) {
		int size = BitmapCacheManagementTask.MESSAGE_CLOSE;
		String temp = "";
		int i;
		if (breed == null || breed.length() <= 0) {
			if (list.size() <= 3) {
				size = list.size();
			}
			if (list == null || list.size() <= 0) {
				return "\u5bb6\u5e38\u83dc";
			}
			for (i = 0; i < size; i++) {
				temp = new StringBuilder(String.valueOf(temp)).append(list.get(i).getName()).append(" ").toString();
			}
			return temp;
		} else if (list == null || list.size() <= 0) {
			return "\u5bb6\u5e38\u83dc";
		} else {
			if (list.size() <= 3) {
				size = list.size();
			}
			for (i = 0; i < size; i++) {
				if (list.get(i).getName().indexOf(breed) != -1) {
					return list.get(i).getName();
				}
				temp = list.get(0).getName();
			}
			return temp;
		}
	}

	public int getCityIndex(String cityname, List<City> list) {
		for (int i = 0; i < list.size(); i++) {
			if (cityname.indexOf(list.get(i).getName()) != -1) {
				return i;
			}
		}
		return 0;
	}

	public String isCookService(CookResult cookResult) {
		if (cookResult.getCity_id() != AppShareData.city_id) {
			return "\u672c\u53a8\u5e08\u4e0e\u60a8\u4e0d\u518d\u540c\u4e00\u4e2a\u57ce\u5e02\uff0c\u8bf7\u60a8\u9884\u7ea6\u5176\u4ed6\u53a8\u5e08\u5427\uff01";
		}
		return cookResult.getStatus() == 0 ? "\u8be5\u53a8\u5e08\u6682\u4e0d\u63d0\u4f9b\u670d\u52a1" : null;
	}
}
